&lt;!--- 
	/* ******************************************************************************************************************************
	 * add application config options here 
	 * base is duplicated in other env.
	 * if a key (e.g. dsn, db) is found in the inheriting environments to other environments, their values will override base config.
	 * to append with "__" suffix (e.g. "abc__") in envs other than base
	 * ******************************************************************************************************************************
	 * Required Keys:
	 * base, current_env
	 * when environment changes, the current_env value should be changed accordingly
	 * ****************************************************************************************************************************** 
	 * Required fields:
	 * dsn, db, context
	 * ******************************************************************************************************************************
	 * When creating dir structure, remeber to escape with '\\'. For e.g. ("temp_dir":"E:\\temp")
	 * ******************************************************************************************************************************
	 * Be careful when specifying the context. If its not directly under the webroot, use the dot notation here.
	 * for e.g. Context:"test.example1"
	 */
---&gt;

<cfset app_dir = rereplace(rereplace(rereplace(cgi.SCRIPT_NAME,'/','.','ALL'),'.','','one'),'.RunGenerator.cfm','', 'ALL') />
<cfset app_dot = rereplace(app_dir,'(#application.env.context#[a-zA-Z\._-]+)$','#form.context_name#', 'ALL') />

<cfset component_dot = replace(app_dot,"railo.","","ALL") />

&lt;cfcomponent&gt;
	&lt;cfset config.json = "" /&gt;
	&lt;cffunction access="private" returntype="void" name = "init"&gt;
		&lt;cfset config.json = '{
			"env":{
				"base":{
					"dsn":"<cfoutput>#form.dsn_name#</cfoutput>",
					"db":"<cfoutput>#form.db_name#</cfoutput>",
					"admin":"admin@domain.com",
					"temp_dir":"E:\\temp",
					"context":"<cfoutput>#app_dot#</cfoutput>",
					"component_location":"<cfoutput>#component_dot#</cfoutput>",
					"pretty_urls":<cfoutput>#form.pretty_urls#</cfoutput>,
					"showdebug":false
				},
				"development":{
					"admin":"dev-bugs-group@domain.com",
					"showdebug":true
				},
				"qa":{
					"admin__":"qa-group@domain.com",
					"showdebug":true
				},
				"uat":{
					"admin__":"uat-group@domain.com"
				},
				"production":{
					"dsn":"prod_valid_dsn",
					"admin__":"admin@domain.com"
				}
			},
			"current_env":"development"
		}' /&gt;
	&lt;/cffunction&gt;
	
	&lt;cffunction access="public" returntype="Struct" name = "getConfig"&gt;
		&lt;cfset init() /&gt;
		&lt;cfset config = DeserializeJSON(config.json) /&gt;
		
		&lt;cfloop collection="#config.env#" item="i"&gt;
			&lt;cfif i NEQ "base"&gt;
				&lt;cfif config.current_env  NEQ i&gt;
					&lt;cfset StructDelete(config.env, i) /&gt;
				&lt;cfelse&gt;
					&lt;cfloop collection="#config.env.base#" item="j"&gt;
						&lt;cfif StructKeyExists(config.env["#i#"], "#j#__")&gt;
							&lt;cfset config.env["#i#"]["#j#"] = listAppend(config.env["#i#"]["#j#__"], #config.env["base"][j]#) /&gt;
							&lt;cfset StructDelete(config.env["#i#"], "#j#__")&gt;
						&lt;/cfif&gt;
						&lt;cfif NOT StructKeyExists(config.env["#i#"], j)&gt;
							&lt;cfset config.env["#i#"]["#j#"] = #config.env["base"][j]# /&gt;
						&lt;/cfif&gt;
					&lt;/cfloop&gt;	
				&lt;/cfif&gt;
			&lt;/cfif&gt;
		&lt;/cfloop&gt;
		
		&lt;cfset StructDelete(config.env, "base") /&gt;
		
		&lt;cfreturn config /&gt;
	&lt;/cffunction&gt;
&lt;/cfcomponent&gt;